<template>
  <div>
    <!-- <div class="img_box" v-if="fileList.length > 0">
      <img v-for="item in fileList" :key="item.name" :src="item.url">
    </div> -->
    <el-button type="primary" @click="openWindowFile">上传</el-button>
    <input ref="file" style="display: none;" type="file" accept="video/*" @change="handleChange">
  </div>
</template>

<script>
export default {
  data() {
    return {
      fileList: [],
    };
  },
  methods: {
    openWindowFile() {
      this.$refs.file.dispatchEvent(new MouseEvent('click')) 
    },
    handleChange(file) {
      let files = file.target.files
      let arr = []
      for (let item of files) {
        console.log(item);
        arr.push({
          name: item.name,
          url: URL.createObjectURL(item)
        })
      }
      this.fileList = arr
      // let data = file.target.files[0].name
      console.log(arr);
      // this.fileList.push({
      //   name: "food2.jpeg",
      //   url: file.target.value
      // })
    }
  },
};
</script>

<style>

</style>
